﻿Imports Kimmo
Imports System.IO

Public Class frmSourceCode
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
        Else
            Dim strFile As String = WebSite.GetQueryValue("file")
            If Len(strFile) > 0 Then
                    Dim content As String = File.ReadAllText(Server.MapPath(strFile))
                    Dim language As String = "ASPX"
                    Dim filename As String = strFile.ToLower
                    If (filename.EndsWith(".aspx")) Then
                        language = "ASPX"
                    ElseIf (filename.EndsWith(".c")) Then
                        language = "C"
                        ElseIf (filename.EndsWith(".cob")) Then
                        language = "COBOL"
                        ElseIf (filename.EndsWith(".cfm")) Then
                        language = "ColdFusion"
                        ElseIf (filename.EndsWith(".e")) Then
                        language = "Eiffel"
                        ElseIf (filename.EndsWith(".for")) Then
                        language = "Fortran"
                        ElseIf (filename.EndsWith(".hs")) Then
                        language = "Haskell"
                        ElseIf (filename.EndsWith(".java")) Then
                        language = "Java"
                            ElseIf (filename.EndsWith(".jscript")) Then
                        language = "JScript"
                            ElseIf (filename.EndsWith(".m")) Then
                        language = "Mercury"
                              ElseIf (filename.EndsWith(".pe")) Then
                        language = "MSIL"
                              ElseIf (filename.EndsWith(".pas")) Then
                        language = "Pascal"
                              ElseIf (filename.EndsWith(".pl")) Then
                        language = "Perl"
                              ElseIf (filename.EndsWith(".php")) Or filename.EndsWith(".php3") Then
                        language = "PHP"
                              ElseIf (filename.EndsWith(".py")) Then
                        language = "Python"
                              ElseIf (filename.EndsWith(".ruby")) Then
                        language = "Ruby"
                              ElseIf (filename.EndsWith(".sql")) Then
                        language = "SQL"
                              ElseIf (filename.EndsWith(".vbs")) Then
                        language = "VisualBasicScript"
                    ElseIf (filename.EndsWith(".vb")) Then
                        language = "VisualBasic"
                    ElseIf (filename.EndsWith(".cs")) Then
                        language = "C#"
                    ElseIf (filename.EndsWith(".config") Or filename.EndsWith(".sitemap") Or filename.EndsWith(".xml")) Then
                        language = "XML"
                    ElseIf filename.EndsWith(".html") Or filename.EndsWith(".htm") Then
                        language = "XML"
                    ElseIf (filename.EndsWith(".css")) Then
                        language = "CSS"
                    ElseIf (filename.EndsWith(".js")) Then
                        language = "JavaScript"
                    End If

                    SyntaxHighlighter1.Mode = Wilco.Web.SyntaxHighlighting.HighlightMode.Source
                    SyntaxHighlighter1.Language = language
                    SyntaxHighlighter1.Text = content
                End If
        End If
    End Sub

End Class